package com.gpay.erp.web.control;

import com.gpay.erp.services.common.GlobalStatus;
import com.gpay.erp.web.util.WebUtil;
import com.gpay.erp.web.vo.ResponseInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.support.RequestContext;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Locale;
import java.util.Map;

/**
 * Created by Administrator on 2015/9/2 0002.
 */
@Controller
@RequestMapping("/global/")
public class GlobalStatusController extends BaseController {
    private Log log = LogFactory.getLog(UserController.class);
    @Autowired
    private MessageSource messageSource;
    @Autowired
    private GlobalStatus globleStatus;

    /**
     * 合同状态查询
     * @param request
     * @param response
     */
    @RequestMapping("contractStatus")
    public void contractStatus(HttpServletRequest request,
                               HttpServletResponse response) {
        RequestContext requestContext = new RequestContext(request);
        ResponseInfo responseInfo = new ResponseInfo();
        responseInfo.setResult("00000");
        responseInfo.setMessage(messageSource.getMessage("select.success",
                new Object[]{}, Locale.CHINA));
        Map map = globleStatus.getContractStatus();
        responseInfo.setObject(map);
        WebUtil.responseToJson(response, responseInfo);

    }

    /**
     * 采购申请状态查询
     * @param request
     * @param response
     */
    @RequestMapping("status")
    public void status(HttpServletRequest request, HttpServletResponse response) {

        RequestContext requestContext = new RequestContext(request);
        ResponseInfo responseInfo = new ResponseInfo();
        responseInfo.setResult("00000");
        responseInfo.setMessage(messageSource.getMessage("select.success",
                new Object[]{}, Locale.CHINA));
        Map map = globleStatus.getStatus();
        responseInfo.setObject(map);
        WebUtil.responseToJson(response, responseInfo);

    }

    /**
     * 税率查询
     * @param request
     * @param response
     */
    @RequestMapping("taxRate")
    public void taxRate(HttpServletRequest request,
                              HttpServletResponse response) {

        ResponseInfo responseInfo = new ResponseInfo();
        responseInfo.setResult("00000");
        responseInfo.setMessage(messageSource.getMessage("select.success",
                new Object[]{}, Locale.CHINA));
        Map map = globleStatus.getTaxRate();
        responseInfo.setObject(map);
        WebUtil.responseToJson(response, responseInfo);

    }

    /**
     * 付款申请状态 查询
     * @param request
     * @param response
     */
    @RequestMapping("paidStatus")
    public void paidStatus(HttpServletRequest request,
                        HttpServletResponse response) {

        ResponseInfo responseInfo = new ResponseInfo();
        responseInfo.setResult("00000");
        responseInfo.setMessage(messageSource.getMessage("select.success",
                new Object[]{}, Locale.CHINA));
        Map map = globleStatus.getPaidStatus();
        responseInfo.setObject(map);
        WebUtil.responseToJson(response, responseInfo);
    }

    /**
     * 付款方式查询
     * @param request
     * @param response
     */
    @RequestMapping("payMethod")
    public void payMethod(HttpServletRequest request,
                          HttpServletResponse response) {

        ResponseInfo responseInfo = new ResponseInfo();
        responseInfo.setResult("00000");
        responseInfo.setMessage(messageSource.getMessage("select.success",
                new Object[]{}, Locale.CHINA));
        Map map = globleStatus.getPayMethod();
        responseInfo.setObject(map);
        WebUtil.responseToJson(response, responseInfo);
    }

    /**
     * 付款类型查询
     * @param request
     * @param response
     */
    @RequestMapping("paymentOrderType")
    public void paymentOrderType(HttpServletRequest request,
                           HttpServletResponse response) {

        ResponseInfo responseInfo = new ResponseInfo();
        responseInfo.setResult("00000");
        responseInfo.setMessage(messageSource.getMessage("select.success",
                new Object[]{}, Locale.CHINA));
        Map map = globleStatus.getPaymentOrderType();
        responseInfo.setObject(map);
        WebUtil.responseToJson(response, responseInfo);
    }

    /**
     * 币种查询
     * @param request
     * @param response
     */
    @RequestMapping("currencys")
    public void currencys(HttpServletRequest request,
                          HttpServletResponse response) {

        ResponseInfo responseInfo = new ResponseInfo();
        responseInfo.setResult("00000");
        responseInfo.setMessage(messageSource.getMessage("select.success",
                new Object[]{}, Locale.CHINA));
        Map map = globleStatus.getCurrencys();
        responseInfo.setObject(map);
        WebUtil.responseToJson(response, responseInfo);
    }
    /**
     * 查询库存状态
     * @param request
     * @param response
     */
    @RequestMapping("storageStatus")
    public void storageStatus(HttpServletRequest request,
                          HttpServletResponse response) {

        ResponseInfo responseInfo = new ResponseInfo();
        responseInfo.setResult("00000");
        responseInfo.setMessage(messageSource.getMessage("select.success",
                new Object[]{}, Locale.CHINA));
        Map map = globleStatus.getStorageStatus();
        responseInfo.setObject(map);
        WebUtil.responseToJson(response, responseInfo);
    }
}
